<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * HITI AdminCP
 *
 * @package     HITI AdminCP Project
 * @since       Monday, October 21, 2013, 6:00 PM
 * @final       
 * @category    Controllers
 * @see 		Image load
 * @author      PHUOCNGUYEN - HITI Dev Team
 * @copyright   Copyright (c) 2013, HITI Corp
 */

class Image_load extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->load->model('image_load_model', 'Img');
	}

	public function index()
	{
		redirect();
	}

	public function letter()
	{
		/*
		* Kiem tra id
		*/
		$id = $this->input->get('i', true);
		if(!$id)
		{
			redirect();
		}
		/*
		* Xu ly du lieu
		*/
		$info = $this->Img->letter($id);
		$email = $this->input->get('e', true);
		$emails = json_decode($info['emails']);
		$email_ids = array();
		foreach ($emails as $key => $value) {
			if ($email == $key) $value = time();
			$email_ids[$key] = $value;
		}
		$emails = json_encode($email_ids);
		$data = array(
			'emails' => $emails
		);
		/*
		* Ghi du lieu
		*/
		$this->Img->process_letter($data, $id);
	}

	public function contact()
	{
		/*
		* Kiem tra id
		*/
		$id = $this->input->get('i', true);
		if(!$id)
		{
			redirect();
		}
		/*
		* Xu ly du lieu
		*/
		$data = array(
			'date_view' => time(),
			'ip' => $this->input->ip_address()
		);
		/*
		* Ghi du lieu
		*/
		$this->Img->process_contact($data, $id);
	}

}


/* End of file Image_load.php */
/* Location: ./application/controllers/Image_load.php */